package com.nutricia.common.util;

import com.nutricia.core.ex.BizErrorCode;
import com.nutricia.core.ex.BizException;

import org.apache.commons.lang3.StringUtils;

/**
 * @author: huangsheng
 * @date: 2018/4/11
 */
public final class CheckUtil {

    /**
     * 校验参数是否为空
     *
     * @param str
     * @param description
     */
    public static void isNotBlank(String str, String description) {
        if (StringUtils.isBlank(str)) {
            throw new BizException(BizErrorCode.PARAM_EMPTY, description);
        }
    }
    
    public static void isNotNull(String str, String description) {
        if (str == null) {
            throw new BizException(BizErrorCode.PARAM_EMPTY, description);
        }
    }
    
    /**
     * isTrue
     *
     * @param value
     * @param errorCodeEnum
     * @param description
     */
    public static void isTrue(boolean value, BizErrorCode errorCodeEnum, String description) {
        if (!value) {
            throw new BizException(errorCodeEnum, description);
        }
    }
}
